using System;
using StartForm;
using System.Threading;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Windows;

namespace X3DXNA
{
#if WINDOWS || XBOX
    static class Program
    {
        static public String fileName;
        static private MainWindow window;
        static Application app;
         
        static void Main(string[] args)
        {
            startThreadWPF();
        }

        public static void startThreadWPF()
        {
            var processWindow = new Thread(new ThreadStart(startWindow));
            processWindow.SetApartmentState(ApartmentState.STA);
            processWindow.Start();
            processWindow.Join();

            fileName = window.fileName;

            if (fileName != null)
            {
                using (Game1 game = new Game1())
                {
                    game.Run();
                }
            }
        }

        private static void startWindow()
        {
            if (Application.Current != null)
                Application.Current.Shutdown();
            app = new System.Windows.Application();
            window = new StartForm.MainWindow();
            app.Run(window);
        }
    }
#endif
}

